import { JXDef } from "../../../conventions/JXCommon";
import GViewBase from "../../../Core/GView/GViewBase";
import { Res } from "../../Common/UIResources";
import GameMgr from "../../Logic/GameMgr";


const { ccclass, property, menu } = cc._decorator;

@ccclass @menu('View/Home/SkillPage')
export default class SkillPage extends GViewBase {

    @property({ type: cc.Label, tooltip: "技能名字" }) skillName: cc.Label = null;
    @property({ type: cc.Sprite, tooltip: "技能图片" }) skillImg: cc.Sprite = null;
    @property({ type: cc.Label, tooltip: "技能信息" }) skillInfo: cc.Label = null;
    @property({ type: cc.Label, tooltip: "技能解锁条件" }) skillLock: cc.Label = null;

    @property({ type: cc.Node, tooltip: "技能信息" }) skillBtn: cc.Node = null;
    /**装备品质名称 */
    private _carName = [];
    onGStart(data: SSkillDataRaw, num?: number) {
        if (num == 1) {
            this.skillLock.node.active = false;
            this.skillBtn.active = true;
        }
        this.initCarName();
        this.initView(data);
    }

    /**初始化卡牌品质名称 */
    protected initCarName() {
        let white = GameMgr.systemConfig.value(JXDef.SYS_CONFIG_KEY.white);
        this._carName.push(white);
        let green = GameMgr.systemConfig.value(JXDef.SYS_CONFIG_KEY.green);
        this._carName.push(green);
        let Blue = GameMgr.systemConfig.value(JXDef.SYS_CONFIG_KEY.Blue);
        this._carName.push(Blue);
        let purple = GameMgr.systemConfig.value(JXDef.SYS_CONFIG_KEY.purple);
        this._carName.push(purple);
        let orange = GameMgr.systemConfig.value(JXDef.SYS_CONFIG_KEY.orange);
        this._carName.push(orange);
        let red = GameMgr.systemConfig.value(JXDef.SYS_CONFIG_KEY.red);
        this._carName.push(red);
        // console.log('展示属性', GameMgr.systemConfig.value(JXDef.SYS_CONFIG_KEY.white));
        // console.log('this._carName', this._carName);
    }

    public initView(data: SSkillDataRaw) {
        this.skillName.string = data.name;
        this.skillInfo.string = data.txt;
        this.skillInfo.spacingX = 10;
        this.skillLock.string = '解锁等级：品质=' + this._carName[data.unlockingState[0]] + data.unlockingState[1] + '级';
        this.assetImpl.spriteAtlasFrame(this.skillImg, Res.texture.views.skillIcon, data.icon.toString());
    }

    public close() {
        this.onClose();
    }
}
